/*
 * Created by JFormDesigner on Tue Jul 02 12:54:57 CST 2024
 */

package scct.ZhuZhouXing.ui;

import scct.ZhuZhouXing.dao.ProductDao;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author xzy
 */
public class DljProductDele extends JDialog {
    int id;

    public DljProductDele(Window owner, int id) {
        super(owner);
        this.id = id;
        initComponents();
    }

    private void btndetele(ActionEvent e) {
        ProductDao productDao = new ProductDao();
        if (productDao.deProduct(id)) {
            JOptionPane.showMessageDialog(this, "删除成功！");
            PaneProductManager.getTable();
            dispose();
        }
    }

    private void btnlic(ActionEvent e) {
        this.dispose();
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        // Generated using JFormDesigner Evaluation license - 老登
        btndetele = new JButton();
        btnlic = new JButton();
        label1 = new JLabel();

        //======== this ========
        Container contentPane = getContentPane();
        contentPane.setLayout(null);

        //---- btndetele ----
        btndetele.setText("\u5220\u9664");
        btndetele.addActionListener(e -> btndetele(e));
        contentPane.add(btndetele);
        btndetele.setBounds(new Rectangle(new Point(55, 145), btndetele.getPreferredSize()));

        //---- btnlic ----
        btnlic.setText("\u53d6\u6d88");
        btnlic.addActionListener(e -> btnlic(e));
        contentPane.add(btnlic);
        btnlic.setBounds(225, 145, 78, 30);

        //---- label1 ----
        label1.setText("\u786e\u5b9a\u5220\u9664\u6b64\u5546\u54c1");
        label1.setFont(label1.getFont().deriveFont(label1.getFont().getSize() + 6f));
        contentPane.add(label1);
        label1.setBounds(120, 40, 185, 75);

        {
            // compute preferred size
            Dimension preferredSize = new Dimension();
            for(int i = 0; i < contentPane.getComponentCount(); i++) {
                Rectangle bounds = contentPane.getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = contentPane.getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            contentPane.setMinimumSize(preferredSize);
            contentPane.setPreferredSize(preferredSize);
        }
        setSize(400, 300);
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    // Generated using JFormDesigner Evaluation license - 老登
    private JButton btndetele;
    private JButton btnlic;
    private JLabel label1;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
